package com.lezhu.plcsdklibrary;


import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class OperatListUtls {

    private static OperatListUtls operatListUtls;
    SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm:ss");
    private static List<String> strings;

    public static OperatListUtls getInstance() {
        if (operatListUtls == null) {
            operatListUtls = new OperatListUtls();
            strings = new ArrayList<>();
        }
        return operatListUtls;
    }


    OperatListUtlsListener operatListUtlsListener;

    public OperatListUtls setListener(OperatListUtlsListener listener) {
        this.operatListUtlsListener = listener;
        return this;
    }

    public void addLog(String log, int type) {
        if (operatListUtlsListener != null) {
            operatListUtlsListener.addlog(log, type);
        }
        Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
        String strDate = formatter.format(curDate);
        String aa = log + "时间是==" + strDate;
        strings.add(aa);
    }

    public void addLog(String log) {
        addLog(log, 1);
    }

    public interface OperatListUtlsListener {
        void addlog(String log, int type);
    }
}

